#pragma oce
#include<unordered_map>
#include<fstream>
#include"log.hpp"
extern Log lg;
std::string filename="dict.txt";
std::string separator=":";
static bool split(const std::string&line,std::string*ptr1,std::string*ptr2)
{
    auto pos=line.find(separator);
    if(pos!=std::string::npos)
    {
        *ptr1=line.substr(0,pos);
        *ptr2=line.substr(pos+1);
        return true;
    }
    return false;
}
class Init
{
    private:
    std::unordered_map<std::string,std::string> dict_;
    public:
    Init()
    {
        std::ifstream in(filename);
        if(!in.is_open())
        {
            lg(FATAL,"Ifstream open fail!!");
            exit(1);}
        std::string line;
        while(getline(in,line))
        {
            std::string ptr1,ptr2;
            split(line,&ptr1,&ptr2);
            dict_.insert({ptr1,ptr2});
        }
        in.close();
    }
    std::string translation(std::string&word)
    {
        auto iter=dict_.find(word);
        if(iter!=dict_.end())
        {
            return iter->second;
        }
        return "Unknow";
    }
    ~Init()
    {

    }
};